package hlhj.fhp.supreme.activitys

import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.lzy.okgo.OkGo
import com.lzy.okgo.model.Response
import hlhj.fhp.supreme.BaseAty
import hlhj.fhp.supreme.R
import hlhj.fhp.supreme.javabean.BaseBean
import hlhj.fhp.supreme.network.Urls
import hlhj.fhp.supreme.utils.JsonCallBack
import hlhj.fhp.supreme.utils.MyUtils
import kotlinx.android.synthetic.main.activity_report_aty.*

class ReportAty : BaseAty() {
    override fun getContentId(): Int = R.layout.activity_report_aty


    override fun initListener() {
        btExit.setOnClickListener {
            finish()
        }
        btCommit.setOnClickListener {
            if (etContent.text.isEmpty())return@setOnClickListener
            OkGo.post<BaseBean>(Urls.BaseUrl+Urls.REPORT)
                    .params("content",etContent.text.toString())
                    .execute(object :JsonCallBack<BaseBean>(this){
                        override fun onSuccess(response: Response<BaseBean>?) {
                            val bean = response?.body()
                            if (bean?.code==1){
                                MyUtils.toast("提交成功")
                                finish()
                            }else{
                                MyUtils.toast("提交失败")
                                finish()
                            }
                        }
                    })
        }
    }

}
